import Taro, { Component } from "@tarojs/taro";
import { View } from "@tarojs/components";

import AuthRoute from "../../components/AuthRoute/authRoute";
import MainContent from "../../components/MainContent/mainContent";
import "./index.less";

class Index extends Component {
  config = {
    navigationBarTitleText: "Planet计划"
  };

  constructor(props) {
    super(props);
    this.state = {
      systemInfo: undefined
    };
  }

  componentWillMount() {
    Taro.getSystemInfo().then(res => {
      this.setState({ systemInfo: res });
    });
  }

  render() {
    let systemInfo = this.state.systemInfo;
    return (
      <View
        className='index'
        style={{
          width: systemInfo ? systemInfo.windowWidth + "px" : "auto",
          height: systemInfo ? systemInfo.windowHeight + "px" : "auto"
        }}
      >
        <AuthRoute />
        <MainContent />
      </View>
    );
  }
}

export default Index;
